import Vue from 'vue'
import App from './App'
// import {layout} from './layout'

import VueResource from 'vue-resource'
import VueRouter from 'vue-router'


Vue.use(VueResource)
Vue.use(VueRouter)
//布局
// layout()

//增加timeout的回调
Vue.http.interceptors.push((request, next) => {
    var timeout;
	// 這裡改用 _timeout ，就不會觸發原本的
    if (request._timeout) {
    	// 一樣綁定一個定時器，但是這裡是只要觸發了，就立即返回 response ， 並且這邊自定義了 status 和 statusText
        timeout = setTimeout(() => {
            if(request.onTimeout) request.onTimeout(request)
			request.abort()
        }, request._timeout);
    }

    next((response) => {
        clearTimeout(timeout);
    });
})


const router=new VueRouter()

router.map({
	'/Home':{
		component:require('./components/Home.vue')
	},
	'/List/:typeId':{
		name:'type',
		component:require('./components/List.vue'),
		subRoutes:{
			'/:contentId':{
				name:'content',
				component:require('./components/Content.vue')
			}
		}
	}
	// ,
	// '/:content':{
	// 	name:'content',
	// 	component:require('./components/Content.vue')
	// }

	
})
router.redirect({
	'*':'/Home'
})
router.start(App,'#app')

